package cn.chencaiju.day13;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

//创建客户端，发送请求
public class Client {
	public static void main(String[] args) {
		Socket socket=null;
		DataOutputStream os=null;
		
		try {
			BufferedReader reader=new BufferedReader(
					new InputStreamReader(System.in,"utf-8"));
			//主机，端口
			socket=new Socket("127.0.0.1",10086);
			System.out.println("已经连上！");
			os=new DataOutputStream(
					new BufferedOutputStream(socket.getOutputStream()));
//			is=socket.getInputStream();
			os.writeUTF("中国");
			os.flush();
			while(true) {
				String str=reader.readLine();
				os.writeUTF(str);
				os.flush();
				System.out.println(str);
				if(str=="88") {
					break;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}finally {
			Utils.closeQuietly(os);
			Utils.closeQuietly(socket);
		}
	}
}
